<template>
  <div>
    <el-button type="primary" size="default" @click="handleDrawer(null)"
      >新增账号</el-button
    >
    <el-table :data="userList" border stripe>
      <el-table-column prop="username" label="账号名称"> </el-table-column>
      <el-table-column label="账号角色">
        <template slot-scope="scope">
          {{ scope.row.roleId }}
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="small"
            @click="handleDrawer(scope.row)"
            >编辑</el-button
          >
          <el-popconfirm
            title="确定不是手抖了吗？"
            confirmButtonText="确认"
            cancelButtonText="取消"
            confirmButtonType="primary"
            cancelButtonType="text"
            icon="el-icon-question"
            iconColor="#f90"
            @confirm="handleDel(scope.row, scope.$index)"
          >
            <el-button slot="reference" type="danger" size="small"
              >删除</el-button
            >
          </el-popconfirm>
        </template>
      </el-table-column>
    </el-table>
    <el-drawer
      title="账号分配"
      :visible.sync="visible"
      direction="rtl"
      size="30%"
    >
      <AccountForm />
    </el-drawer>
  </div>
</template>

<script>
import { userGet } from "@/api/user";
import AccountForm from "./components/account-form.vue";
export default {
  components: {
    AccountForm,
  },
  data() {
    return {
      userList: [],
      visible: false,
    };
  },
  created() {
    userGet().then((res) => {
      console.log(res);
      this.userList = res.data.results;
    });
  },
  methods: {
    handleDrawer() {
      this.visible = true;
    },
  },
};
</script>

<style lang="scss" scoped></style>
